﻿using MediatR;
using W.Purchase.API.Application.Command.ClientCommand;
using W.Purchase.Domain;
using W.Purchase.Repository.Interface;

namespace W.Purchase.API.Application.CommandHandler.ClientCommandHandler
{
    public class ClienContactDelCommandHandler : IRequestHandler<ClienContactDelCommand, int>
    {
        private IClientContactRepository clientContact;
        public ClienContactDelCommandHandler(IClientContactRepository clientContact)
        {
            this.clientContact = clientContact;
        }
        public async Task<int> Handle(ClienContactDelCommand request, CancellationToken cancellationToken)
        {
            var list = await clientContact.GetModelAsync(request.ClientContactId);
            list.IsDelete = true;
            list.DeleteTime = DateTime.Now;
            return await clientContact.Update(list);
        }
    }
    }

